package com.xc.controller.backend;

import com.xc.common.ServerResponse;
import com.xc.service.MenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;

@Controller
@RequestMapping({"/admin/menu/"})
public class AdminMenuController {
    private static final Logger log = LoggerFactory.getLogger(AdminAgentController.class);
    @Autowired
    MenuService menuService;

    //新增菜单
    @RequestMapping({"insert.do"})
    @ResponseBody
    public ServerResponse insert(@RequestParam LinkedHashMap<String, Object> params) throws Exception {
        return ServerResponse.createBySuccess(this.menuService.insertMenu(params));
    }

    //更新菜单
    @RequestMapping({"update.do"})
    @ResponseBody
    public ServerResponse update(@RequestParam LinkedHashMap<String, Object> params) {
        return ServerResponse.createBySuccess(this.menuService.updateMenu(params));
    }

    //删除菜单
    @RequestMapping({"delete.do"})
    @ResponseBody
    public ServerResponse delete(@RequestParam(value = "menuId") Integer menuId) {
        return ServerResponse.createBySuccess(this.menuService.deleteMenu(menuId));
    }

    //菜单列表
    @RequestMapping({"menuList.do"})
    @ResponseBody
    public ServerResponse menuList(@RequestParam LinkedHashMap<String, String> params) throws Exception  {
        return this.menuService.menuList(params);
    }

}
